<style>
    a#addlink{
        text-decoration: none;
        color: black;
    }
</style>
<script type="text/javascript">
    $(document).ready(function(){
       $('div#add').hide();
       $('a#addlink').click(function(event){
           event.preventDefault();
           var add = document.getElementById("add");
           if(add.style.display == 'none'){
               $('div#add').show('fast');
               $('a#addlink').html('- Tambah Kategori');
           }
           else {
               $('div#add').hide('fast');
               $('a#addlink').html('+ Tambah Kategori');
           }
       });
    });

    function add(){
  
  //untuk dapatin make id
    var a = document.getElementById('form');
        a.submit();
    }

    //untuk delete
    function delCategory(categoryID, categoryName){
        if(!confirm('Hapus ' + categoryName + '?')) return;

        document.frmDelete.categoryID.value = categoryID;
        document.frmDelete.categoryName.value = categoryName;
        document.frmDelete.submit();
    }

</script>
<div id="view-content">
    <h3><a id="addlink" href="#">+ Tambah Kategori</a></h3>
    <div id="add" style="padding-bottom: 10px;">
        <?php echo $this->form;?>
        <a class="abutton" href="javascript:add();">
            <img src="<?php echo $this->baseUrl(); ?>/images/icons/add.png"/> Tambah
        </a>
        <br>
    </div>
    <h3>- Daftar Kategori</h3>
    <table>
        <tr class="head">
            <td>ID</td>
            <td>Nama </td>
            <td>Keterangan</td>
            <td>Ubah </td>
            
        </tr>
        <?php
        foreach($this->categories as $category){
        ?>
        <tr style="background-color: <?= $this->cycle(array("#ccffcc","#99ff99"))->next(); ?>;">
            <td><?php echo $this->escape($category->category_id); ?></td>
            
            <td><?php echo $this->escape($category->name); ?></td>
            <td><?php echo $this->escape($category->details); ?></td>
            
           
            <td>
                
                <a href="<?php echo $this->url(array("controller"=>"shop", "action"=>"editcategory", "id"=>$this->escape($category["category_id"])));?>" title="Edit">
                    <img src="<?php echo $this->baseUrl(); ?>/images/icons/pencil.png" alt="Ubah" />
                </a>
            </td>
        </tr>
        <?php
        }
        ?>
    </table>
    <div id="hiddenform" style="display:none;">
        <form name="frmDelete" action="category" method="POST">
            <?php echo $this->formHidden("categoryID","0"); ?>
            <?php echo $this->formHidden("categoryName",""); ?>
            <?php echo $this->formHidden("delete","Hapus"); ?>
        </form>
    </div>
</div>